﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;
using Models;

namespace Web
{
    public partial class UserView : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                goodsTypeRepeater();
                if (Session["UserID"] != null)
                {
                    List<UserinforModel> list = UserinforManger.selectByUserID(int.Parse(Session["UserID"].ToString()));
                    string UserName = list[0].UName;
                    Label2.Text= UserName;
                    Label1.Text = "<li><a href='UserInfoAdjust.aspx'>信息编辑</a></li>";
                }
                else
                {
                    Label1.Text = "<li><a href='Login.aspx'>【登录】</a></li><li><a href='register.aspx'>【注册】</a></li>";
                    Label2.Text = "未登录";
                }

            }
        }
        void goodsTypeRepeater()
        {
            GoodsTypeBLL gt = new GoodsTypeBLL();
            List<GoodsTypeModels> list = gt.selectAll();
            Repeater1.DataSource = list;
            Repeater1.DataBind();
        }

        protected void Unnamed_Click(object sender, EventArgs e)//分类按钮
        {
            int GoodsTypeID = Convert.ToInt32(((Button)sender).CommandArgument);
            //Session["GoodsTypeID"] = GoodsTypeID;
            Response.Redirect("ProductType.aspx?GoodsTypeID="+GoodsTypeID);
        }

        protected void btn1_Click(object sender, EventArgs e)//搜索按钮
        {
            //Response.Write("<script>alert('"+Request["searchText"].ToString()+"')</script>");

            Response.Redirect("SearchGoods.aspx?Search=" + TextBox1.Text);
        }
    }
}